/**
 * 
 */
package com.java.test.timer;

import com.java.test.activity.activitypush.dto.AddActivityDTO;
import com.java.test.messagecenter.dto.NoticeInfo;
import com.java.test.messagecenter.dto.PushMessageInfo;
import com.java.test.messagecenter.mapper.NoticeMapper;
import com.java.test.messagecenter.mapper.PushMessageMapper;
import com.java.test.messagecenter.messagepush.dto.SendMailDTO;
import com.java.test.paymanage.dto.PayChannelInfo;
import com.java.test.paymanage.dto.PayTypeInfo;
import com.java.test.paymanage.dto.SkAccountInfo;
import com.java.test.paymanage.mapper.PayChannelMapper;
import com.java.test.paymanage.mapper.PayTypeMapper;
import com.java.test.paymanage.mapper.SkAccountMapper;
import com.java.test.platmanage.dto.GameListInfo;
import com.java.test.platmanage.dto.PlatParamInfo;
import com.java.test.platmanage.mapper.GameListMapper;
import com.java.test.platmanage.mapper.PlatParamMapper;
import com.java.test.system.feesettings.FeeSettingsDAO;
import com.java.test.system.feesettings.entity.FundsTypeEntity;
import com.java.test.system.fundstypemanage.FundsTypeDAO;
import com.java.test.system.fundstypemanage.dto.FundsTypeQueryDTO;
import com.java.test.system.gametypemanage.GameTypeManageDAO;
import com.java.test.system.gametypemanage.dto.GameTypeQueryDTO;
import com.java.test.system.gametypemanage.entity.GameTypeEntity;
import com.java.test.system.registrationtemplate.RegistrationTemplateDAO;
import com.java.test.system.registrationtemplate.dto.RegistrationTemplateQueryDTO;
import com.java.test.system.registrationtemplate.entity.RegistrationTemplateEntity;
import com.java.test.user.dto.BankAccountInfo;
import com.java.test.user.dto.BlackIpInfo;
import com.java.test.user.dto.DrawingChannelInfo;
import com.java.test.user.dto.MemberGradeInfo;
import com.java.test.user.mapper.BlackIpMapper;
import com.java.test.user.mapper.PlayAccountMapper;
import com.java.test.user.service.DrawingMangeService;
import com.java.test.user.service.MemberService;
import com.java.test.util.RequestGameServiceUtil;
import lombok.extern.slf4j.Slf4j;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.util.*;
import java.util.concurrent.ConcurrentLinkedQueue;

/**
 * @author 推送消息定时任务
 *
 */
@Slf4j
@Component
@EnableScheduling
public class MessagePushTimer {

	@Autowired
	SkAccountMapper skAccountMapper;

	@Autowired
	PayTypeMapper payTypeMapper;

	@Autowired
	PayChannelMapper payChannelMapper;

	@Autowired
	private BlackIpMapper blackIpMapper;

	@Autowired
	private NoticeMapper noticeMapper;

	@Autowired
	private PushMessageMapper pushMessageMapper;

	@Autowired
	PlayAccountMapper playAccountMapper;

	@Autowired
	GameListMapper gameListMapper;

	@Autowired
	PlatParamMapper platParamMapper;

	@Autowired
	private GameTypeManageDAO gameTypeManageDAO;

	@Autowired
	private FeeSettingsDAO feeSettingsDAO;

	@Autowired
	private MemberService memberservice;

	@Autowired
	private DrawingMangeService drawingMangeService;

	@Autowired
	private FundsTypeDAO fundsTypeDAO;

	@Autowired
	private RegistrationTemplateDAO registrationTemplateDAO;

	@Value("${get.game.offLineUser.url}")
	public String offLineUserUrl;

	//支付类型队列
	public static ConcurrentLinkedQueue<String> payTypeCLQ = new ConcurrentLinkedQueue<String>();
	//资金类型队列
	public static ConcurrentLinkedQueue<String> fundsCLQ = new ConcurrentLinkedQueue<String>();
	//注册类型队列
	public static ConcurrentLinkedQueue<String> registrationCLQ = new ConcurrentLinkedQueue<String>();
	//支付渠道队列
	public static ConcurrentLinkedQueue<String> payChannelCLQ = new ConcurrentLinkedQueue<String>();
	//黑名单队列
	public static ConcurrentLinkedQueue<String> ipCLQ = new ConcurrentLinkedQueue<String>();
	//会员分层队列
	public static ConcurrentLinkedQueue<String> userGradeCLQ = new ConcurrentLinkedQueue<String>();
	//提款渠道队列
	public static ConcurrentLinkedQueue<String> drawingChannelCLQ = new ConcurrentLinkedQueue<String>();
	//游戏大类队列
	public static ConcurrentLinkedQueue<String> gameTypeCLQ = new ConcurrentLinkedQueue<String>();
	//游戏大类队列
	public static ConcurrentLinkedQueue<String> gameALLCLQ = new ConcurrentLinkedQueue<String>();
	//取款手续费推送
	public static ConcurrentLinkedQueue<String> QKFeeCLQ = new ConcurrentLinkedQueue<String>();



	//邮件用户列表
    public static List<SendMailDTO> sendMailList = new ArrayList<>();

    //活动
    public static List<AddActivityDTO> activityList = new ArrayList<>();

	//要停止运行的跑马灯
	public static List<Integer> idListStop = new ArrayList<>();

	//页面公告删除
	public static List<Integer> pageAnnouncementListStop = new ArrayList<>();

	//禁用用户id
	public static List<String> disableUserIdList = new ArrayList<>();

	//启用用户id
	public static List<String> enableUserIdList = new ArrayList<>();

	//提款账户userId
	public static List<String> withdrawalAccountList = new ArrayList<>();

	//修改用户信息
	public static List<Map<String,Object>> updateUserInfoList = new ArrayList<>();

	//游戏列表
	public static List<String> gameList = new ArrayList<>();

	//游戏平台列表
	public static List<String> gameALLList = new ArrayList<>();

	boolean flag = false;//游戏列表推送

	@Scheduled(cron = "*/3 * * * * ?")
	public void run() {
//		messageCenterService.handlepushMessage();
		StringBuffer str = new StringBuffer();
		str.append("payTypeCLQ:").append(payTypeCLQ.size()).append("*********");
		str.append("fundsCLQ:").append(fundsCLQ.size()).append("*********");
		str.append("registrationCLQ:").append(registrationCLQ.size()).append("*********");
		str.append("payChannelCLQ:").append(payChannelCLQ.size()).append("*********");
		str.append("ipCLQ:").append(ipCLQ.size()).append("*********");
		str.append("userGradeCLQ:").append(userGradeCLQ.size()).append("*********");
		str.append("drawingChannelCLQ:").append(drawingChannelCLQ.size()).append("*********");
		str.append("sendMailList:").append(sendMailList.size()).append("*********");
		str.append("activityList:").append(activityList.size()).append("*********");
		str.append("disableUserIdList:").append(disableUserIdList.size()).append("*********");
		str.append("enableUserIdList:").append(enableUserIdList.size()).append("*********");
		str.append("withdrawalAccountList:").append(withdrawalAccountList.size()).append("*********");
		str.append("pageAnnouncementListStop:").append(pageAnnouncementListStop.size()).append("*********");
		str.append("idListStop:").append(idListStop.size()).append("*********");
		str.append("gameList:").append(gameList.size()).append("*********");
		str.append("gameTypeCLQ:").append(gameTypeCLQ.size()).append("*********");
		str.append("QKFeeCLQ:").append(QKFeeCLQ.size()).append("*********");


//		System.out.println(str.toString());
		if(!payTypeCLQ.isEmpty()){
			payTypePush();
		}
		if(!fundsCLQ.isEmpty()){
			fundsTypePush();
		}
		if(!registrationCLQ.isEmpty()){
			registrationTypePush();
		}
		if(!payChannelCLQ.isEmpty()){
			payChannelPush();
		}
		if(activityList.size()>0){
            activityPush();
        }
		if(!ipCLQ.isEmpty()){
			ipBlacklistPush();
		}
		if(!userGradeCLQ.isEmpty()){
			userGradePush();
		}
		if(!drawingChannelCLQ.isEmpty()){
			drawingChannelPush();
		}
		if(idListStop.size()>0){
			horseRaceLampDeletePush();
		}
		if(pageAnnouncementListStop.size()>0){
			noticeDeletePush();
		}
		if(disableUserIdList.size()>0){
			accountOperationDisablePush();
		}
		if(enableUserIdList.size()>0){
			accountOperationEnablePush();
		}
		if(withdrawalAccountList.size()>0){
			withdrawalAccountPush();
		}
		if(updateUserInfoList.size()>0){
			updateUserInfoPush();
		}
		if(gameList.size()>0){
			gameListPush();
		}
		if(!gameALLCLQ.isEmpty()){
			gameListAllPush();
		}
		if(!gameTypeCLQ.isEmpty()){
			gameTypeSortPush();
		}
		if (!QKFeeCLQ.isEmpty()){
			QKFeeSortPush();
		}
		horseRaceLampPush();
		pageAnnouncementPush();
		sendMailPush();
	}

	/**
	 * 跑马灯公告 2
	 * @author
	 * @date 2020/7/31 0031 14:58
	 * @return void
	 */
	private void horseRaceLampPush(){
		List<NoticeInfo> list = noticeMapper.selectHorseRaceLampPushList(LocalDateTime.now(),2);
		if(list.size()>0){
			System.out.println("**********我是定时任务2**********");
		}
		for (NoticeInfo obj:list) {
			String base64Sign = new String(Base64.getEncoder().encode(obj.getContent().getBytes()));
			JSONArray stra = new JSONArray();
			stra.put(base64Sign);
			int powerType = 0;
			if(obj.getPowerType()==2){
				powerType= 1;
			}else if(obj.getPowerType()==3){
				powerType = 2;
			}
			stra.put(powerType);
			stra.put(-1);
			stra.put(Long.toString(obj.getId()));
			JSONObject data=new JSONObject();
			data.put("code",2);
			data.put("data",stra);
			String time = new Date().getTime() + "";
			Random r1 = new Random();
			String url = RequestGameServiceUtil.createUrl(time, r1.nextInt(100) + "", data.toString(), offLineUserUrl);
			JSONObject resMsg = RequestGameServiceUtil.getService(url);
			if (resMsg != null) {
				String state = (resMsg.get("state").toString());
				if ("0".equals(state)) {
					noticeMapper.updateHorseRaceLampStatus(obj.getId());
					log.info(resMsg.get("message").toString());
				} else {
					log.info(resMsg.get("message").toString());
				}
			}
		}
	}

	/**
     * 邮件推送  3
     * @author lijie1
     * @date 2020/7/20 0020 16:01
     * @return void
     */
	private void sendMailPush(){
		List<PushMessageInfo> list = pushMessageMapper.selectPushMessageList(LocalDateTime.now());
		if(list.size()>0){
			System.out.println("**********我是定时任务3**********");
		}
        for (PushMessageInfo obj:list) {
			JSONArray stra=new JSONArray();
			JSONArray str=new JSONArray(obj.getPushItemAccount());
            stra.put(str);
            stra.put(obj.getTitle());
            stra.put(obj.getContent());
            /*Iterator iter = obj.getTools().entrySet().iterator();
            JSONObject st=new JSONObject();
            while (iter.hasNext()) {
                Map.Entry entry = (Map.Entry) iter.next();
                String key = entry.getKey().toString();
                Object val = entry.getValue();
                st.put(key,val);
            }
            stra.put(st);*/
            JSONObject data=new JSONObject();
            data.put("code",3);
            data.put("data",stra);
			String time = new Date().getTime()+"";
			Random r1 = new Random();
			System.out.println(data.toString());
            String url =  RequestGameServiceUtil.createUrl(time,r1.nextInt(100)+"",data.toString(),offLineUserUrl);
            JSONObject resMsg = RequestGameServiceUtil.getService(url);
            if(resMsg!=null){
                String state = (resMsg.get("state").toString());
                if("0".equals(state)){
					pushMessageMapper.updatePushMessageStatus(Integer.toString(obj.getId()));
                    log.info(resMsg.get("message").toString());
                }else {
                    log.info(resMsg.get("message").toString());
                }
            }
        }
    }

    /**
     * 活动推送  4
     * @author lijie1
     * @date 2020/7/20 0020 16:14
     * @return void
     */
	private void activityPush(){
        System.out.println("**********我是定时任务4**********");
        String time = new Date().getTime()+"";
        Random r1 = new Random();
        JSONArray stra=new JSONArray();
        for (int i =0;i<activityList.size();i++) {
            AddActivityDTO obj = activityList.get(i);
            stra.put(obj.getTitle());
            String base64Sign = new String(Base64.getEncoder().encode(obj.getContent().getBytes()));
            stra.put(base64Sign);
            stra.put(obj.getStartTime());
            stra.put(obj.getEndTime());
            stra.put(obj.getHeadUrl());
            stra.put(obj.getType());
            stra.put(obj.getUrl());
            JSONObject data=new JSONObject();
            data.put("code",4);
            data.put("data",stra);
            String url =  RequestGameServiceUtil.createUrl(time,r1.nextInt(100)+"",data.toString(),offLineUserUrl);
            JSONObject resMsg = RequestGameServiceUtil.getService(url);
            if(resMsg!=null){
                String state = (resMsg.get("state").toString());
                if("0".equals(state)){
                    sendMailList.remove(i);
                    log.info(resMsg.get("message").toString());
                }else {
                    log.info(resMsg.get("message").toString());
                }
            }
        }
    }

    /**
     * 页面公告推送  5
     * @author lijie1
     * @date 2020/7/20 0020 16:07
     * @return void
     */
	private void pageAnnouncementPush(){
		List<NoticeInfo> list = noticeMapper.selectHorseRaceLampPushList(LocalDateTime.now(),1);
		if(list.size()>0){
			System.out.println("**********我是定时任务5**********");
		}
        for (NoticeInfo obj:list){
			JSONArray stra=new JSONArray();
            stra.put(obj.getTitle());
            String base64Sign = new String(Base64.getEncoder().encode(obj.getContent().getBytes()));
            stra.put(base64Sign);
            stra.put(obj.getPushTime().toEpochSecond(ZoneOffset.of("+8")));
            stra.put(-1);
			stra.put(obj.getId());
            JSONObject data=new JSONObject();
            data.put("code",5);
            data.put("data",stra);
			String time = new Date().getTime()+"";
			Random r1 = new Random();
            String url =  RequestGameServiceUtil.createUrl(time,r1.nextInt(100)+"",data.toString(),offLineUserUrl);
            JSONObject resMsg = RequestGameServiceUtil.getService(url);
            if(resMsg!=null){
                String state = (resMsg.get("state").toString());
                if("0".equals(state)){
					noticeMapper.updateHorseRaceLampStatus(obj.getId());
                    log.info(resMsg.get("message").toString());
                }else {
                    log.info(resMsg.get("message").toString());
                }
            }
        }
    }

	/**
	 * 资金类型推送 6
	 * @author
	 * @date 2020/7/15 0015 15:07
	 * @return void
	 */
	private void fundsTypePush() {
		System.out.println("**********我是定时任务6**********");
		List<FundsTypeEntity> entityList = fundsTypeDAO.getFundsTypeList(new FundsTypeQueryDTO());
		String time = new Date().getTime()+"";
		JSONArray stra=new JSONArray();
		for (FundsTypeEntity entity:entityList) {
			JSONArray str=new JSONArray();
			str.put(entity.getFullName());
			str.put(entity.getName());
			str.put(entity.getRate());
			str.put(entity.getIsDefault());
			stra.put(str);
		}
		JSONObject data=new JSONObject();
		data.put("code",6);
		data.put("data",stra);
		Random r1 = new Random();
		String url =  RequestGameServiceUtil.createUrl(time,r1.nextInt(100)+"",data.toString(),offLineUserUrl);
		JSONObject resMsg = RequestGameServiceUtil.getService(url);
		if(resMsg!=null){
			String state = (resMsg.get("state").toString());
			if("0".equals(state)){
				fundsCLQ = new ConcurrentLinkedQueue<String>();
				log.info(resMsg.get("message").toString());
			}else {
				log.info(resMsg.get("message").toString());
			}
		}
	}

	/**
	 * 支付类型排序推送  7
	 * @author 
	 * @date 2020/7/15 0015 15:05 
	 * @return void
	 */
	private void payTypePush() {
		System.out.println("**********我是定时任务7**********");
		List<PayTypeInfo> list = payTypeMapper.selectPayTypeListByStatus();
		String time = new Date().getTime()+"";
		JSONArray stra=new JSONArray();
		for (PayTypeInfo entity:list) {
			stra.put(String.valueOf(entity.getId()));
		}
		JSONObject data=new JSONObject();
		data.put("code",7);
		data.put("data",stra);
		Random r1 = new Random();
		String url =  RequestGameServiceUtil.createUrl(time,r1.nextInt(100)+"",data.toString(),offLineUserUrl);
		JSONObject resMsg = RequestGameServiceUtil.getService(url);
		if(resMsg!=null){
			String state = (resMsg.get("state").toString());
			if("0".equals(state)){
				payTypeCLQ = new ConcurrentLinkedQueue<String>();
				log.info(resMsg.get("message").toString());
			}else {
				log.info(resMsg.get("message").toString());
			}
		}
	}

	/**
	 * 注册类型推送  8
	 * @author
	 * @date 2020/7/15 0015 15:07
	 * @return void
	 */
	private void registrationTypePush() {
		System.out.println("**********我是定时任务8**********");
		RegistrationTemplateQueryDTO dto = new RegistrationTemplateQueryDTO();
		dto.setStatus(1);
		List<RegistrationTemplateEntity> entityList = registrationTemplateDAO.getSelectByList(dto);
		String time = new Date().getTime()+"";
		JSONArray stra=new JSONArray();
		for (RegistrationTemplateEntity entity:entityList) {
			JSONArray str=new JSONArray();
			str.put(String.valueOf(entity.getType()));
			JSONArray st=new JSONArray();
			for (int i =0;i<entity.getFieldId().split(",").length;i++){
				st.put(Integer.parseInt(entity.getFieldId().split(",")[i]));
			}
			str.put(st);
			stra.put(str);
		}
		JSONObject data=new JSONObject();
		data.put("code",8);
		data.put("data",stra);
		Random r1 = new Random();
		//log.info(data.toString());
		String url =  RequestGameServiceUtil.createUrl(time,r1.nextInt(100)+"",data.toString(),offLineUserUrl);
		JSONObject resMsg = RequestGameServiceUtil.getService(url);
		if(resMsg!=null){
			String state = (resMsg.get("state").toString());
			if("0".equals(state)){
				registrationCLQ = new ConcurrentLinkedQueue<String>();
				log.info(resMsg.get("message").toString());
			}else {
				log.info(resMsg.get("message").toString());
			}
		}

	}

	/**
	 * 支付渠道推送  9
	 * @author 
	 * @date 2020/7/18 0018 10:03 
	 * @return void
	 */
	private void payChannelPush(){
		System.out.println("**********我是定时任务9**********");
		PayChannelInfo queryDTO = new PayChannelInfo();
		queryDTO.setPayType(100);
		List<PayChannelInfo> entityList1 = payChannelMapper.selectpaychanneList(queryDTO);
		String time = new Date().getTime()+"";
		JSONArray stra=new JSONArray();
		for (PayChannelInfo entity1:entityList1) {
			JSONArray str=new JSONArray();
			str.put(String.valueOf(entity1.getId()));
			str.put(entity1.getChannelName());
			str.put(entity1.getIconUrl());
			str.put(entity1.getGfrealmname());
			JSONArray st=new JSONArray();
			List<SkAccountInfo> entityList = skAccountMapper.selectSKAccount(Integer.toString(entity1.getId()));
			int stor = -1;
			for (SkAccountInfo entity:entityList) {
				if(stor<0 || stor == entity.getSort()){
					stor = entity.getSort();
					JSONArray s=new JSONArray();
					s.put(entity.getSkAccount());
					s.put(entity.getSkAccounName());
					s.put(entity.getFoundsTypeName());
					s.put(Double.parseDouble(entity.getYhproportion())*10000);
					st.put(s);
				}
			}
			if(st.length()>0){
				str.put(st);
				stra.put(str);
			}
		}
		JSONObject data=new JSONObject();
		data.put("code",9);
		data.put("data",stra);
		Random r1 = new Random();
		String url =  RequestGameServiceUtil.createUrl(time,r1.nextInt(100)+"",data.toString(),offLineUserUrl);
		JSONObject resMsg = RequestGameServiceUtil.getService(url);
		if(resMsg!=null){
			String state = (resMsg.get("state").toString());
			if("0".equals(state)){
				payChannelCLQ = new ConcurrentLinkedQueue<String>();
				log.info(resMsg.get("message").toString());
			}else {
				log.info(resMsg.get("message").toString());
			}
		}
	}

	/**
	 * 黑名单ip推送 10
	 * @author lijie1
	 * @date 2020/7/24 0024 14:59 
	 * @return void
	 */
	private void ipBlacklistPush(){
		System.out.println("**********我是定时任务10**********");
		List<BlackIpInfo> list = blackIpMapper.selectBlackIpList();
		JSONArray stra=new JSONArray();
		for (BlackIpInfo info:list) {
			String ips = info.getIpAddress();
			if (ips == null || "".equals(ips)){
				return;
			}
			ips = ips.replace("~","_");
			String str[] = ips.split("_");
			if (str.length < 2) {
				ips = ips.substring(0, ips.length() - 1);
			}
			info.setIpAddress(ips);
			stra.put(info.getIpAddress());
		}
		String time = new Date().getTime()+"";
		JSONObject data=new JSONObject();
		data.put("code",10);
		data.put("data",stra);
		Random r1 = new Random();
		String url =  RequestGameServiceUtil.createUrl(time,r1.nextInt(100)+"",data.toString(),offLineUserUrl);
		JSONObject resMsg = RequestGameServiceUtil.getService(url);
		if(resMsg!=null){
			String state = (resMsg.get("state").toString());
			if("0".equals(state)){
				ipCLQ = new ConcurrentLinkedQueue<>();
				log.info(resMsg.get("message").toString());
			}else {
				log.info(resMsg.get("message").toString());
			}
		}
	}

	/**
	 * 会员等级条件推送 11
	 * @author
	 * @date 2020/7/28 0028 15:37
	 * @return void
	 */
	private void userGradePush(){
		System.out.println("**********我是定时任务11**********");
		JSONArray stra=new JSONArray();
		List<MemberGradeInfo> infoList = memberservice.selectMemberGradeListOrderBy();
		for (MemberGradeInfo info:infoList) {
			stra.put(info.getUpLvExp());
		}
		JSONObject data=new JSONObject();
		data.put("code",11);
		data.put("data",stra);
		System.out.println(data.toString());
		String time = new Date().getTime()+"";
		Random r1 = new Random();
		String url =  RequestGameServiceUtil.createUrl(time,r1.nextInt(100)+"",data.toString(),offLineUserUrl);
		JSONObject resMsg = RequestGameServiceUtil.getService(url);
		if(resMsg!=null){
			String state = (resMsg.get("state").toString());
			if("0".equals(state)){
				userGradeCLQ = new ConcurrentLinkedQueue<>();
				log.info(resMsg.get("message").toString());
			}else {
				log.info(resMsg.get("message").toString());
			}
		}
	}

	/**
	 * 提款渠道推送 12
	 * @author 
	 * @date 2020/7/28 0028 15:32 
	 * @return void
	 */
	private void drawingChannelPush(){
		System.out.println("**********我是定时任务12**********");
		JSONArray stra=new JSONArray();
		List<DrawingChannelInfo> list = drawingMangeService.selectdrawingchannelList(new DrawingChannelInfo());
		for (DrawingChannelInfo info:list) {
			JSONArray str=new JSONArray();
			str.put(String.valueOf(info.getId()));
			str.put(info.getChannelName());
			str.put(info.getImgUrl());
			str.put("USDT");
			stra.put(str);
		}
		JSONObject data=new JSONObject();
		data.put("code",12);
		data.put("data",stra);
		System.out.println(data.toString());
		String time = new Date().getTime()+"";
		Random r1 = new Random();
		String url =  RequestGameServiceUtil.createUrl(time,r1.nextInt(100)+"",data.toString(),offLineUserUrl);
		JSONObject resMsg = RequestGameServiceUtil.getService(url);
		if(resMsg!=null){
			String state = (resMsg.get("state").toString());
			if("0".equals(state)){
				drawingChannelCLQ = new ConcurrentLinkedQueue<>();
				log.info(resMsg.get("message").toString());
			}else {
				log.info(resMsg.get("message").toString());
			}
		}
	}

	/**
	 * 删除公告(跑马灯) 13
	 * @author 
	 * @date 2020/7/31 0031 13:45 
	 * @return void
	 */
	private void horseRaceLampDeletePush(){
		System.out.println("**********我是定时任务13跑马灯**********");
		JSONArray stra=new JSONArray();
		for (int i = 0;i<idListStop.size();i++){
			JSONArray str=new JSONArray();
			str.put(1);
			str.put(Integer.toString(idListStop.get(i)));
			stra.put(str);
		}
		JSONObject data=new JSONObject();
		data.put("code",13);
		data.put("data",stra);
		System.out.println(data.toString());
		String time = new Date().getTime()+"";
		Random r1 = new Random();
		String url =  RequestGameServiceUtil.createUrl(time,r1.nextInt(100)+"",data.toString(),offLineUserUrl);
		JSONObject resMsg = RequestGameServiceUtil.getService(url);
		if(resMsg!=null){
			String state = (resMsg.get("state").toString());
			if("0".equals(state)){
				idListStop = new ArrayList<>();
				log.info(resMsg.get("message").toString());
			}else {
				log.info(resMsg.get("message").toString());
			}
		}
	}

	/**
	 * 删除公告(普通公告) 13
	 * @author
	 * @date 2020/7/31 0031 13:45
	 * @return void
	 */
	private void noticeDeletePush() {
		System.out.println("**********我是定时任务13普通公告**********");
		JSONArray stra = new JSONArray();
		for (int i = 0; i < pageAnnouncementListStop.size(); i++) {
			JSONArray str = new JSONArray();
			str.put(2);
			str.put(Integer.toString(pageAnnouncementListStop.get(i)));
			stra.put(str);
		}
		JSONObject data = new JSONObject();
		data.put("code", 13);
		data.put("data", stra);
		String time = new Date().getTime() + "";
		Random r1 = new Random();
		String url = RequestGameServiceUtil.createUrl(time, r1.nextInt(100) + "", data.toString(), offLineUserUrl);
		JSONObject resMsg = RequestGameServiceUtil.getService(url);
		if (resMsg != null) {
			String state = (resMsg.get("state").toString());
			if ("0".equals(state)) {
				pageAnnouncementListStop = new ArrayList<>();
				log.info(resMsg.get("message").toString());
			} else {
				log.info(resMsg.get("message").toString());
			}
		}
	}

	/**
	 * 会员禁用推送 14
	 * @author
	 * @date 2020/8/5 0005 14:09
	 * @return void
	 */
	private void accountOperationDisablePush(){
		System.out.println("**********我是定时任务14禁用**********");
		JSONArray stra = new JSONArray();
		stra.put(2);
		JSONArray str = new JSONArray();
		for (String userId:disableUserIdList) {
			str.put(userId);
		}
		stra.put(str);
		JSONObject data = new JSONObject();
		data.put("code", 14);
		data.put("data", stra);
		String time = new Date().getTime() + "";
		Random r1 = new Random();
		String url = RequestGameServiceUtil.createUrl(time, r1.nextInt(100) + "", data.toString(), offLineUserUrl);
		JSONObject resMsg = RequestGameServiceUtil.getService(url);
		if (resMsg != null) {
			String state = (resMsg.get("state").toString());
			if ("0".equals(state)) {
				disableUserIdList = new ArrayList<>();
				log.info(resMsg.get("message").toString());
			} else {
				log.info(resMsg.get("message").toString());
			}
		}
	}

	/**
	 * 会员启用推送 14
	 * @author
	 * @date 2020/8/5 0005 14:09
	 * @return void
	 */
	private void accountOperationEnablePush(){
		System.out.println("**********我是定时任务14启用**********");
		JSONArray stra = new JSONArray();
		stra.put(1);
		JSONArray str = new JSONArray();
		for (String userId:enableUserIdList) {
			str.put(userId);
		}
		stra.put(str);
		JSONObject data = new JSONObject();
		data.put("code", 14);
		data.put("data", stra);
		String time = new Date().getTime() + "";
		Random r1 = new Random();
		String url = RequestGameServiceUtil.createUrl(time, r1.nextInt(100) + "", data.toString(), offLineUserUrl);
		JSONObject resMsg = RequestGameServiceUtil.getService(url);
		if (resMsg != null) {
			String state = (resMsg.get("state").toString());
			if ("0".equals(state)) {
				enableUserIdList = new ArrayList<>();
				log.info(resMsg.get("message").toString());
			} else {
				log.info(resMsg.get("message").toString());
			}
		}
	}

	/**
	 * 提款账户推送  15
	 * @author
	 * @date 2020/8/5 0005 14:37
	 * @return void
	 */
	private void withdrawalAccountPush(){
		System.out.println("**********我是定时任务15**********");
		for (int i = 0; i < withdrawalAccountList.size(); i++) {
			String userId = withdrawalAccountList.get(i);
			BankAccountInfo info = new BankAccountInfo();
			info.setGameAccount(userId);
			String uniqueNo = playAccountMapper.getUniqueNumber(userId);
			JSONArray stra = new JSONArray();
			stra.put(uniqueNo);
			List<BankAccountInfo> bankAccountInfos =  memberservice.selectBankAccountListPush(info);
			JSONArray str = new JSONArray();
			for (BankAccountInfo bankAccountInfo:bankAccountInfos) {
				if(bankAccountInfo.getBankAccount()!=null&&!"".equals(bankAccountInfo.getBankAccount())){
					JSONArray st = new JSONArray();
					st.put(bankAccountInfo.getBankAccount());
					st.put(bankAccountInfo.getBankAccountName());
					st.put(Integer.toString(bankAccountInfo.getDrawingType()));
					st.put(bankAccountInfo.getDrawingTypeName());
					st.put(1);
					str.put(st);
				}

			}
			stra.put(str);
			JSONObject data = new JSONObject();
			data.put("code", 15);
			data.put("data", stra);
			String time = new Date().getTime() + "";
			Random r1 = new Random();
			String url = RequestGameServiceUtil.createUrl(time, r1.nextInt(100) + "", data.toString(), offLineUserUrl);
			JSONObject resMsg = RequestGameServiceUtil.getService(url);
			if (resMsg != null) {
				String state = (resMsg.get("state").toString());
				if ("0".equals(state)) {
					withdrawalAccountList.remove(i);
					log.info(resMsg.get("message").toString());
				} else {
					log.info(resMsg.get("message").toString());
				}
			}
		}
	}

	/**
	 * 推送语言包  16
	 * @author 
	 * @date 2020/8/10 0010 15:15 
	 * @return void
	 */
	private void voicePackPush(){
		System.out.println("**********我是定时任务16**********");
		JSONArray stra = new JSONArray();
		JSONArray str = new JSONArray();
		str.put("语言id");
		str.put("标题");
		str.put("图标");
		str.put(1);
		stra.put(str);

		JSONObject data = new JSONObject();
		data.put("code", 16);
		data.put("data", stra);
		String time = new Date().getTime() + "";
		Random r1 = new Random();
		String url = RequestGameServiceUtil.createUrl(time, r1.nextInt(100) + "", data.toString(), offLineUserUrl);
		JSONObject resMsg = RequestGameServiceUtil.getService(url);
		if (resMsg != null) {
			String state = (resMsg.get("state").toString());
			if ("0".equals(state)) {
				System.err.println("9999999999999999999999999999999999999999999999999999999999999999");
				log.info(resMsg.get("message").toString());
			} else {
				log.info(resMsg.get("message").toString());
			}
		}
	}

	/**
	 * 修改会员信息  17
	 * @author
	 * @date 2020/8/10 0010 15:15
	 * @return void
	 */
	private void updateUserInfoPush(){
		System.out.println("**********我是定时任务17**********");

		for (int i = 0;i<updateUserInfoList.size();i++) {
			Map<String,Object> map = updateUserInfoList.get(i);

			JSONArray stra = new JSONArray();
			stra.put(map.get("userId").toString());
			stra.put(Integer.parseInt(map.get("type").toString()));
			stra.put(map.get("pam").toString());
			JSONObject data = new JSONObject();
			data.put("code", 17);
			data.put("data", stra);
			String time = new Date().getTime() + "";
			Random r1 = new Random();
			System.out.println("******************"+data);
			String url = RequestGameServiceUtil.createUrl(time, r1.nextInt(100) + "", data.toString(), offLineUserUrl);
			JSONObject resMsg = RequestGameServiceUtil.getService(url);
			if (resMsg != null) {
				String state = (resMsg.get("state").toString());
				if ("0".equals(state)) {
					updateUserInfoList.remove(i);
					log.info(resMsg.get("message").toString());
				} else {
					log.info(resMsg.get("message").toString());
				}
			}
		}



	}

	/**
	 * 游戏列表  18（单游戏通知）
	 * @author
	 * @date 2020/8/10 0010 15:15
	 * @return void  {"code":18,"data": [["平台  (1  2pt 3Mg)","游戏唯一性码","动作 （1增加/改 ,2删除）","游戏类型  1solt  2 直播","排序值","标签0无 1new  2 host",是不是老虎机热门 1是 0不是],....]}
	 */
	private void gameListPush() {
		System.out.println("**********我是定时任务18（单）**********");
		JSONArray stra = new JSONArray();
		for (String gameNo:gameList) {
			List<GameListInfo> gameListInfoList =  gameListMapper.selectGameByGameNo(gameNo);
			GameListInfo entity = gameListInfoList.get(0);
			JSONArray str = new JSONArray();
			str.put(Integer.toString(entity.getPlatId()));
			str.put(entity.getGameCode());
			str.put(entity.getStatus()==1?1:2);
			str.put(entity.getGameName());
			str.put(Integer.toString(entity.getGameType()));
			str.put(entity.getSort());
			if(entity.getIsNotHot()==1){
				str.put(2);
			}else {
				str.put(0);
			}
			str.put(entity.getIsNotTigerHot());
			stra.put(str);
		}
		JSONObject data = new JSONObject();
		data.put("code", 18);
		data.put("data", stra);
		String time = new Date().getTime() + "";
		Random r1 = new Random();
		System.out.println("******************" + data);
		String url = RequestGameServiceUtil.createUrl(time, r1.nextInt(100) + "", data.toString(), offLineUserUrl);
		JSONObject resMsg = RequestGameServiceUtil.getService(url);
		if (resMsg != null) {
			String state = (resMsg.get("state").toString());
			if ("0".equals(state)) {
				gameList = new ArrayList<>();
				log.info(resMsg.get("message").toString());
			} else {
				log.info(resMsg.get("message").toString());
			}
		}
	}

	/**
	 * 游戏列表  18（游戏平台关闭批量通知）
	 * @author
	 * @date 2020/8/10 0010 15:15
	 * @return void  {"code":18,"data": [["平台  (1  2pt 3Mg)","游戏唯一性码","动作 （1增加/改 ,2删除）","游戏类型  1solt  2 直播","排序值","标签0无 1new  2 host",是不是老虎机热门 1是 0不是],....]}
	 */
	private void gameListAllPush() {
		System.out.println("**********我是定时任务18（批量）**********");
		JSONArray stra = new JSONArray();
		Iterator<String> iterator = gameALLCLQ.iterator();
		while (iterator.hasNext()) {
			String platId = gameALLCLQ.poll();
			if(platId==null){
				break;
			}
			List<GameListInfo> gameListInfoList =  gameListMapper.selectGameByPlatId(platId);
			PlatParamInfo obj = platParamMapper.selectplatInfoById(Integer.parseInt(platId));
			int i = 0;
			for (GameListInfo entity:gameListInfoList) {
				if(obj.getStatus()==0 && entity.getStatus()==1){
					i++;
					JSONArray str = new JSONArray();
					str.put(Integer.toString(entity.getPlatId()));
					str.put(entity.getGameCode());
					str.put(2);
					str.put(entity.getGameName());
					str.put(Integer.toString(entity.getGameType()));
					str.put(entity.getSort());
					if(entity.getIsNotHot()==1){
						str.put(2);
					}else {
						str.put(0);
					}
					str.put(entity.getIsNotTigerHot());
					stra.put(str);
				}
				if (obj.getStatus()==1 && entity.getStatus()==1){
					i++;
					JSONArray str = new JSONArray();
					str.put(Integer.toString(entity.getPlatId()));
					str.put(entity.getGameCode());
					str.put(1);
					str.put(entity.getGameName());
					str.put(Integer.toString(entity.getGameType()));
					str.put(entity.getSort());
					if(entity.getIsNotHot()==1){
						str.put(2);
					}else {
						str.put(0);
					}
					str.put(entity.getIsNotTigerHot());
					stra.put(str);
				}
				if(i>50){
					JSONObject data = new JSONObject();
					data.put("code", 18);
					data.put("data", stra);
					String time = new Date().getTime() + "";
					Random r1 = new Random();
					System.out.println("////////////////////////" + data);
					String url = RequestGameServiceUtil.createUrl(time, r1.nextInt(100) + "", data.toString(), offLineUserUrl);
					JSONObject resMsg = RequestGameServiceUtil.getService(url);
					if (resMsg != null) {
						String state =
								(resMsg.get("state").toString());
						if ("0".equals(state)) {
							stra = new JSONArray();
							i = 0;
						} else {
						}
					}
				}
			}
		}
		if(stra.length()>0){
			JSONObject data = new JSONObject();
			data.put("code", 18);
			data.put("data", stra);
			String time = new Date().getTime() + "";
			Random r1 = new Random();
			System.out.println("******************" + data);
			String url = RequestGameServiceUtil.createUrl(time, r1.nextInt(100) + "", data.toString(), offLineUserUrl);
			JSONObject resMsg = RequestGameServiceUtil.getService(url);
			if (resMsg != null) {
				String state = (resMsg.get("state").toString());
				if ("0".equals(state)) {
					log.info(resMsg.get("message").toString());
				} else {
					log.info(resMsg.get("message").toString());
				}
			}
		}

		flag = false;
	}

	/**
	 * 游戏大类推送
	 * @author lijie1.
	 * @date 2020/9/28 0028 10:04
	 * @return void		 {"code":19,"data": [1,2,3,4,5]}
	 */
	private void gameTypeSortPush(){
		System.out.println("**********我是定时任务19**********");
		JSONArray stra = new JSONArray();
		GameTypeQueryDTO gameTypeQueryDTO = new GameTypeQueryDTO();
		gameTypeQueryDTO.setStatus(1);
		List<GameTypeEntity> list = gameTypeManageDAO.selectGameTypeList(gameTypeQueryDTO);
		for (GameTypeEntity entity:list) {
			stra.put(entity.getId());
		}
		JSONObject data = new JSONObject();
		data.put("code", 19);
		data.put("data", stra);
		String time = new Date().getTime() + "";
		Random r1 = new Random();
		System.out.println("******************" + data);
		String url = RequestGameServiceUtil.createUrl(time, r1.nextInt(100) + "", data.toString(), offLineUserUrl);
		JSONObject resMsg = RequestGameServiceUtil.getService(url);
		if (resMsg != null) {
			String state = (resMsg.get("state").toString());
			if ("0".equals(state)) {
				gameTypeCLQ = new ConcurrentLinkedQueue<String>();
				log.info(resMsg.get("message").toString());
			} else {
				log.info(resMsg.get("message").toString());
			}
		}
	}

	/**
	 * 提款手续费设置
	 * @author 
	 * @date 2020/10/10 0010 14:06
	 * @return void  //提款手续费设置  	{"code":20,"data": [手续费万分比]}
	 */
	private void QKFeeSortPush(){
		System.out.println("**********我是定时任务20**********");
		JSONArray stra = new JSONArray();
		List<Map<String, Object>> list = feeSettingsDAO.getSelectByListOrderBy();
		for (Map<String, Object> map:list) {
			stra.put(map.get("fee_scale"));
		}
		JSONObject data = new JSONObject();
		data.put("code", 20);
		data.put("data", stra);
		String time = new Date().getTime() + "";
		Random r1 = new Random();
		System.out.println("******************" + data);
		String url = RequestGameServiceUtil.createUrl(time, r1.nextInt(100) + "", data.toString(), offLineUserUrl);
		JSONObject resMsg = RequestGameServiceUtil.getService(url);
		if (resMsg != null) {
			String state = (resMsg.get("state").toString());
			if ("0".equals(state)) {
				QKFeeCLQ = new ConcurrentLinkedQueue<String>();
				log.info(resMsg.get("message").toString());
			} else {
				log.info(resMsg.get("message").toString());
			}
		}
	}

}
